package org.jeecg.zhenxuan.Controller;

import com.alibaba.fastjson.JSONObject;
import org.jeecg.zhenxuan.Entity.UsersPoint;
import org.jeecg.zhenxuan.Repository.UserAddRepository;
import org.jeecg.zhenxuan.Repository.UserRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Slf4j
@Controller
public class TestController {

    @Autowired
    private UserAddRepository userAddRepository;
    @Autowired
    private UserRepository userRepository;

/*
    @ResponseBody
    @RequestMapping(value = "DoNOTremove.txt" , method = RequestMethod.HEAD)
    public void testProc10(HttpServletResponse response){
        System.out.println("/DoNOTremove.txt");
        try {
            response.getOutputStream().write("test".getBytes());
        } catch (IOException e) {
            e.printStackTrace();
        }
//        return "test";
    }

    @ResponseBody
    @RequestMapping("/MsgRouter/DoNOTremove.txt")
    public String testProc11(){
        System.out.println("/MsgRouter/DoNOTremove.txt");
        return "test";
    }
*/

    @ResponseBody
    @RequestMapping("/testAdd")
    public JSONObject testAddProc(String name, String openId){

        UsersPoint usersPoint = new UsersPoint();
        usersPoint.setName(name);
        usersPoint.setOpenId(openId);

        userRepository.save(usersPoint);

        JSONObject result = new JSONObject();

        result.put("status", "success");
        return result;
    }

//    private org.slf4j.Logger logger = LoggerFactory.getLogger("logging1");

    @ResponseBody
    @RequestMapping("/testaddacc")
    public void test1(String name ,String name2){

        double count = 0.0;
        while (true){
//            System.out.println("這是什麽？" + count);
            log.info("這是什麽？" + count);

//            logger.info("lasjdfljsdfljslfjsdlk");

//            logger.debug("這是什麽？" + count);

            count += 0.00001;
        }

//        return "";
    }


}
